<?php

class Test_QRcodeHelper {
    
    public function __construct() {
        
        V::addLibrary('third', dirname(V_PATH).'/third-lib/');
    }
    
    public function testCreateSimple() {
        
        $tmpDir = FS::tmpDir();
        $path = $tmpDir.'/qrcode.png';
        $text = time();
        QRcodeHelper::createSimple($text, $path);
        if (!is_file($path)) {
            FS::rmdir($tmpDir);
            return false;
        }
        $content = FS::read($path);
        FS::rmdir($tmpDir);
        echo '<img src="data:image/png;base64,'.base64_encode($content).'" alt="'.$text.'" />';
        return true;
    }
}